﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
	<link href="js-console.css" rel="stylesheet" />
	<!-- 3. Write a script that finds the max and min number 
			from a sequence of numbers -->
</head>
<body>
	<div id="js-console"></div>
	<script src="js-console.js"></script>
	<script>
		//Read input
		var numbersString = prompt("Enter sequence of numbers divided by space");
		var numbers = numbersString.split(' ', 100);

		if (numbers.length > 0) {
			var min = Number.MAX_VALUE;
			var max = Number.MIN_VALUE;

			for (var i in numbers) {
				var num = parseInt(numbers[i], 10);
				if(!isNaN(num))
				{
					if (num < min) {
						min = num;
					}

					if (num > max) {
						max = num;
					}
				}
			}

			if (min != Number.MAX_VALUE) {
				jsConsole.writeLine("Min = " + min);
			}
			if (max != Number.MIN_VALUE) {
				jsConsole.writeLine("Max = " + max);
			}
		}
		else {
			jsConsole.writeLine("Wrong input.");
		}

	</script>
</body>
</html>
